class_name UnitStats
extends Resource

# ===============================================

@export var name: String

@export_category("Data")
@export var rarity: Rarity
@export var pool_count: int = 5
@export var traits: Array[Trait]
@export_range(1, 3) var tier: int = 1 :
	set(value):
		tier = value
		emit_changed()

@export_category("Visuals")
@export var skin_coordinates: Vector2i

@export_category("Battle")
@export var team: Team

# ===============================================

enum Rarity {COMMON, UNCOMMON, RARE, EPIC, LEGENDARY}

const RARITY_COLORS: Array[Color] = [
	Color("666666"),
	Color("124a2e"),
	Color("1c527c"),
	Color("ab0979"),
	Color("ea940b"),
]

const COMBINED_UNIT_REQUIREMENT: int = 3

enum Team {PLAYER, ENEMY}

const TEAM_SPRITESHEET: Array = [
	preload("res://assets/images/rogues.png"),
	preload("res://assets/images/monsters.png")
]

# ===============================================

func get_gold_cost() -> int:
	return rarity + 1


func get_combined_unit_count() -> int:
	return COMBINED_UNIT_REQUIREMENT ** (tier - 1)


func get_gold_value() -> int:
	return get_gold_cost() * get_combined_unit_count()

# ===============================================

# 调试时返回名称，而非id
func _to_string() -> String:
	return name
